#!/usr/bin/perl

$HOME_DIR = "/home/one-tenth";
$HOME_DIR = $ENV{'CHOPSET_HOME'} if($ENV{'CHOPSET_HOME'} ne '');

require "$HOME_DIR/config.ph";
if($ARGV[0] ne 'y'){
	print("Is you need clear all status files?(y/N)\n");
	$dummy = <>;
	unless($dummy =~ m/^y\r?\n$/i){
		print "nothing happend.\n";
		exit(0);
	}
}

print("destroying all worker node processes...\n") if($ARGV[0] ne 'y');
@nodes = &getNodeList();
foreach $node (@nodes){
	print("killing all jobs on $node\n") if($ARGV[0] ne 'y');
	&killAllJobOnNode($node);
}

`rm -rf $WORK_DIR/* $DESTROYED_NODES_FILE $NODE_STATUS_DIR/*`;
print "all status files deleted.\n" if($ARGV[0] ne 'y');
print "success.\n" if($ARGV[0] eq 'y');
